<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title></title>
    <script src="../js/vue.js"></script>
</head>

<body>
    <script>
        Vue.config.productionTip = false;
        let number = 22;
        let person = {
            name:"法外狂徒张三",
            sex:"男"
        };
        Object.defineProperty(person,"age",{
            //读取person的age时会被调用，且返回值是age的值
            get(){
                console.log("有人访问量age属性");
                return number;
            },
            //修改age时会被调用，且会收到修改的具体值
            set(value){
                console.log("有人修改了age，值是",value);
                number = value;
            }
        });

    </script>
</body>

</html>